<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .a {
            height: 100px;
            background-color: #f00;
            position: relative;
        }

        .a1 {
            width: 1000px;
            height: 70px;
            background-color: #ff0;
            position: absolute;
            top: 100px;
            right: 0;
            z-index: 10;
        }


        .b {
            position: fixed;
            width: 100px;
            height: 100px;
            right: 0;
            background-color: #000;
            /* z-index: 5; */
        }

        .b1 {
            position: absolute;
            width: 50px;
            height: 50px;
            top: 0;
            left: -50px;
            background-color: skyblue;
            z-index: 100;
        }
    </style>
</head>

<body>

    <!-- 

        只有一层定位的时候，值越大越靠前
        定位里面继续嵌套定位的时候，z_index的值受父元素的约束

            z-index  不是永远都能做到z-index不是值越大就约靠前    -----  z-index受父元素的约束

     -->


    <div class="a">
        <div class="a1"></div>
    </div>


    <div class="b">
        <div class="b1"></div>
    </div>

</body>

</html>